{include file="common/head"/} 
<div class="admin-main">
    <fieldset class="layui-elem-field layui-field-title"><legend>已确认的订单{:lang('list')}</legend></fieldset>
    <div class="demoTable layui-form"> 
        <div class="layui-inline">
            <select name="shopid" id="shopid" ng-model="field.shopid" lay-filter="shopid" lay-verify="required">
                <option value="">请选择所属商户</option>
                {volist name="shoplist" id="vo"}<option value="{$vo.id}" id="{$vo.name}">{$vo.name}</option>  {/volist}
            </select> 
        </div>
        <div class="layui-inline">
            <select name="channelid" id="channelid" ng-model="field.channelid" lay-filter="channelid" lay-verify="required">
                <option value="">请选择通道</option> 
            </select>
        </div> 
        <div class="layui-inline">
            <select name="state" id="state" ng-model="field.state" lay-filter="state" lay-verify="required">
                <option value="">按支付状态</option>
                <option value="0">待支付</option>
                <option value="1">待确认</option>
                <option value="2">已确认</option> 
                <option value="-1">已删除</option> 
            </select>
        </div>
        <div class="layui-inline">
            <select name="points" id="points" ng-model="field.points" lay-filter="points" lay-verify="required">
                <option value="">按上分状态</option>
                <option value="0">待上分</option>
                <option value="1">自动上分</option>
                <option value="2">手动上分</option>
            </select>
        </div>
        <div class="layui-inline"> 
            <input type="text" class="layui-input" id="timess" placeholder="选择日期"> 
        </div>
        <div class="layui-inline">
            <input class="layui-input" name="orderid" id="orderid" placeholder="平台订单号">
        </div>
        <div class="layui-inline">
            <input class="layui-input" name="orderid_out" id="orderid_out" placeholder="商户订单号">
        </div>
        <button class="layui-btn layui-btn-primary" id="search" data-type="reload">搜索</button>  
    </div>
    <blockquote class="layui-elem-quote" style="margin-top: 10px;"> 
        <span class="green">已确认订单：</span>{$payorder.yes}元，
        <span>商户手续费：</span><span class="layui-btn layui-btn-xs layui-btn-normal">{$payorder.feishop}元</span>，
        <span>码商代理手续费：</span><span class="layui-btn layui-btn-xs layui-btn-normal">{$payorder.feiagent}元</span>，
        <span>码商手续费：</span><span class="layui-btn layui-btn-xs layui-btn-normal">{$payorder.feiuser}元</span>
    </blockquote>
    <table class="layui-table layui-hide" id="orderlist" lay-filter="listss"></table>
</div> 
<script type="text/html" id="topNav">
    <a href="{:url('oklist')}" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe857;</i>全部订单明细</a> 
    <div class="layui-btn layui-btn-sm layui-btn-primary" onclick="orderquan('today')"><i class="layui-icon">&#xe857;</i>今日订单明细</div> 
    <div class="layui-btn layui-btn-sm layui-btn-primary" onclick="orderquan('yesterday')"><i class="layui-icon">&#xe857;</i>昨日订单明细</div> 
    <div class="layui-btn layui-btn-sm layui-btn-primary" onclick="orderquan('week')"><i class="layui-icon">&#xe857;</i>本周订单明细</div> 
    <div class="layui-btn layui-btn-sm layui-btn-primary" onclick="orderquan('last week')"><i class="layui-icon">&#xe857;</i>上周订单明细</div> 
    <div class="layui-btn layui-btn-sm layui-btn-primary" onclick="orderquan('month')"><i class="layui-icon">&#xe857;</i>本月订单明细</div> 
    <div class="layui-btn layui-btn-sm layui-btn-primary" onclick="orderquan('last month')"><i class="layui-icon">&#xe857;</i>上月订单明细</div> 
</script>  
<script type="text/html" id="payinfo"> 
    {{# if(d.bankid){ }}<div onmouseover="layer.tips('{{d.bank_name}}<br>收款账号：{{d.bank_no}}<br>支付时间：{{d.paytime}}',this,{area: 'auto',tips: [1, '#333']});" onmouseout="layer.closeAll();">{{d.payname}}</div>{{# } }} 
</script> 
<script type="text/html" id="shopinfo">
    {{# if(d.orderid_out){ }}
        <div onmouseover="layer.tips('商户订单号：{{d.orderid_out}}',this,{tips: [1, '#333']});" onmouseout="layer.closeAll();">{{d.shopname}}</div>
    {{# }else{ }}
        {{d.shopname}}
    {{# } }}  
</script>  
<script type="text/html" id="action">
    {{# if(d.state==2 && d.points==0){ }}
        <div class="layui-btn layui-btn-danger layui-btn-xs" lay-event="reback">未支付</div>
    {{# }else{ }}
        <div class="layui-btn layui-btn-disabled layui-btn-xs">成功</div>
    {{# } }} 
</script>
<script src="/static/plugins/layui/layui.js"></script> 
<script>
    layui.use(['layer','table','form','laydate'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery, layer = layui.layer,laydate = layui.laydate;;
        laydate.render({
            elem: '#timess',range: true
        });
        tableIn = table.render({
            id: 'listss',
            elem: '#orderlist',
			toolbar: '#topNav',
            url: '{:url("index")}',
            method: 'post', 
            page: true,
            cols: [[ 
                {field: 'orderid', title: '平台订单号',align: 'center', width:138, fixed: true},
                {field: 'cionname', title: '币种名称',align: 'center', width: 120, fixed: true},
                {field: 'money', title: '订单金额',align: 'center', width: 120, fixed: true}, 
                {field: 'price', title: '单价/CNY',align: 'center', width: 100},
                {field: 'number', title: '数量',align: 'center', width: 100},
                {field: 'state_name', title: '订单状态',align: 'center', width: 90}, 
                {field: 'points_name', title: '上分状态',align: 'center', width: 90}, 
                {field: 'payname', title: '支付信息',align: 'center', width: 100,templet: '#payinfo'}, 
                {field: 'fei_shop', title: '商户手续费',align: 'center', width: 100}, 
                {field: 'fei_user', title: '码商手续费',align: 'center', width: 100},   
                {field: 'fei_agent', title: '代理手续费',align: 'center', width: 100},  
                {field: 'channelname', title: '所属通道',align: 'center', width: 120}, 
                {field: 'username', title: '所属码商',align: 'center', width: 100},  
                {field: 'shopname', title: '所属商户',align: 'center', width: 120,templet: '#shopinfo'}, 
                {field: 'note', title: '备注信息',align: 'center', width: 120},  
                {field: 'addtime', title: '提交时间',align: 'center', width: 169},   
                {title: '操作', width: 80,align: 'center', fixed:'right',toolbar: '#action'},
            ]],
            limit: 60,where:{state:2} //每页默认显示的数量
        });  
        //搜索
        $('#search').on('click', function() {
            var shopid = $('#shopid').val();
            var channelid = $('#channelid').val();
            var timess = $('#timess').val();
            var state = $('#state').val();
            var points = $('#points').val();
            var orderid = $('#orderid').val();
            var orderidout = $('#orderid_out').val();
            if($.trim(shopid)==='' && $.trim(channelid)==='' && $.trim(timess)==='' && $.trim(orderid)==='' && $.trim(state)==='' && $.trim(points)==='' ) {
                layer.msg('请输入平台订单号！',{icon:0});
                return;
            }else{
                tableIn.reload({ page: {page: 1},where: {shopid: shopid,channelid: channelid,timess: timess,orderid: orderid,orderidout: orderidout,state: state,points: points}});
            } 
        });
        form.on('select(shopid)', function (data) {
            var shopid = data.value;
            $.get("{:url('channel/getChannel')}?shopid=" + shopid, function (data) {
                var html = '<option value="">请选择通道</option>';
                $.each(data, function (i, value) {
                    html += '<option value="' + value.id + '">' + value.title + '</option>';
                });
                $('#channelid').html(html); 
                form.render()
            });
        }); 
        table.on('tool(listss)', function(obj) {
            var data = obj.data;
            if(obj.event === 'reback') {
                layer.confirm('该订单有疑问，确定变为未支付状态', function(index){ 
                    $.post("{:url('reback')}",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1},function(){
                                tableIn.reload();
                            }); 
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });    
    });
    function orderquan(timessss){
        tableIn.reload({ page: {page: 1},where: {timequan:timessss}}); 
    }
</script>
</body>
</html>